package com.yls.autoapply.util;

import com.yls.autoapply.model.NameSpace;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

public class ServiceUtil {

    private static Map<String, List<NameSpace>> map = new HashMap<>();

    public static void put(String service, List<NameSpace> list) {
        map.put(service, list);
    }

    public static List<NameSpace> get(String service) {
        return map.get(service);
    }

    public static Set<String> getAllkey() {
        return map.keySet();
    }

    public static Map<String, List<String>> basic() {
        Map<String, List<String>> basic = new HashMap<>();
        Set<String> allkey = getAllkey();
        for (String key : allkey) {
            basic.put(key, get(key).stream().map(x -> x.getNamespace()).collect(Collectors.toList()));
        }
        return basic;
    }
}
